package tmproject.hlhj.fhp.tmvote.activitys

import android.view.Gravity
import kotlinx.android.synthetic.main.aty_pay.*
import tmproject.hlhj.fhp.tmvote.BaseAty
import tmproject.hlhj.fhp.tmvote.Content
import tmproject.hlhj.fhp.tmvote.R
import tmproject.hlhj.fhp.tmvote.beans.BaseBean
import tmproject.hlhj.fhp.tmvote.beans.PayBean
import tmproject.hlhj.fhp.tmvote.beans.PayWaysBean
import tmproject.hlhj.fhp.tmvote.customView.EwmDialog
import tmproject.hlhj.fhp.tmvote.customView.EwmPop
import tmproject.hlhj.fhp.tmvote.log
import tmproject.hlhj.fhp.tmvote.module.PayModule
import tmproject.hlhj.fhp.tmvote.presenters.PayPresenter
import tmproject.hlhj.fhp.tmvote.views.PayView
import java.io.File

/**
 * Created by Never Fear   on 2018\8\7 0007.
Never More....
 */
class PayAty :BaseAty<PayView,PayPresenter>(), PayView {
    var payWay=1;
    override fun bindView(): PayView {
        return this
    }

    override fun logicStart() {
    }

    override fun setListener() {
        btPay.setOnClickListener {
            log("fhp","参数表uid=${intent.getStringExtra("uid")}," +
                    "name=${intent.getStringExtra("name")}," +
                    "phone=${intent.getStringExtra("phone")}," +
                    "des=${intent.getStringExtra("des")}," +
                    "id=${intent.getStringExtra("id")}," +
                    "path=${intent.getStringExtra("imgPath")}")
            presenter?.pay(intent.getStringExtra("uid"),intent.getStringExtra("name"),
                    intent.getStringExtra("phone"),intent.getStringExtra("des"),
                    intent.getStringExtra("id"),payWay.toString(),File(intent.getStringExtra("imgPath")),this@PayAty)
        }

        loWechat.setOnClickListener {
            cbWechat.isChecked=true
            payWay=1
        }
        loAli.setOnClickListener {
            cbAli.isChecked=true
            payWay=2
        }
    }

    override fun createPresenter(): PayPresenter {
        return PayPresenter()
    }

    override fun getContentId(): Int {
        return R.layout.aty_pay
    }

    override fun initView() {
        btPay.setBackgroundResource(Content.vote_commit_bottom_bac)
        tvPrice.text=intent.getStringExtra("price")
        cbWechat.isClickable=false
        cbAli.isClickable=false

    }
    override fun onPayResp(payBean: PayBean) {

    }

    override fun setPayWays(payWaysBean: PayWaysBean) {
        loadingDialog.dismiss()
    }

    override fun gotSignResp(baseBean: BaseBean) {
        loadingDialog.dismiss()
        /*EwmDialog(this@PayAty,baseBean.data.toString())
                .show()*/
        EwmPop(this@PayAty,baseBean.data.toString())
                .showAtLocation(father,Gravity.BOTTOM,0,0)

    }
}